// GlobalEvent.ts
import { EventTarget } from 'cc';

class GlobalEvent {
    private static eventTarget = new EventTarget();

    static emit(event: string, ...args: any[]) {
        
        this.eventTarget.emit(event, ...args);
    }

    static on(event: string, callback: (...args: any[]) => void, target?: Object) {

        this.eventTarget.on(event, callback, target);
    }

    static off(event: string, callback: (...args: any[]) => void, target?: Object) {
        
        this.eventTarget.off(event, callback, target);
    }
}

export default GlobalEvent;
